package com.d3.pomodoro.component

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView


class SpacesItemDecoration : RecyclerView.ItemDecoration {
    private var space: Int = 0

    constructor(space: Int) : super() {
        this.space = space
    }

    override
    fun getItemOffsets(
        outRect: Rect, view: View,
        parent: RecyclerView, state: RecyclerView.State
    ) {
        outRect.bottom = space

        // Add top margin only for the first item to avoid double space between items
        if (parent.getChildPosition(view) == 0)
            outRect.top = space
    }
}